/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmConsReceber.java
 *
 * Created on 22/09/2009, 09:41:47
 */
package contaspagar.telas;

import contaspagar.bd.ContasPagarDAO;
import contaspagar.classes.ConsultaContasVencendoTableModel;
import contaspagar.classes.ConsultaContasVencerTableModel;
import contaspagar.classes.ConsultaContasVencidasTableModel;
import contaspagar.classes.ContasPagar;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

/**
 *
 * @author Wolverine
 */
public class FrmConsultaPagar extends javax.swing.JFrame {

    /** Creates new form FrmConsReceber */
    public FrmConsultaPagar() {
        try {
            contasPagarDAO = new ContasPagarDAO();
            String dataDoDia = contasPagarDAO.getDataDoDia();
            System.out.println(dataDoDia);
            List<ContasPagar> listaContasVencendo = contasPagarDAO.getContasVencendo(dataDoDia);
            List<ContasPagar> listaContasVencer = contasPagarDAO.getContasVencer(dataDoDia);
            List<ContasPagar> listaContasVencidas = contasPagarDAO.getContasVencidas(dataDoDia);
            modelVencendo = new ConsultaContasVencendoTableModel(listaContasVencendo);
            modelVencer = new ConsultaContasVencerTableModel(listaContasVencer);
            modelVencidas = new ConsultaContasVencidasTableModel(listaContasVencidas);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage()+"Mensagem");
            modelVencendo = new ConsultaContasVencendoTableModel(new ArrayList<ContasPagar>());
            modelVencer = new ConsultaContasVencerTableModel(new ArrayList<ContasPagar>());
            modelVencidas = new ConsultaContasVencidasTableModel(new ArrayList<ContasPagar>());
        }
        initComponents();
        setLocationRelativeTo(null);
        setVisible(true);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        AssociadosjPanel = new javax.swing.JPanel();
        nomeCedentejTextField = new javax.swing.JTextField();
        nomeCedentejLabel = new javax.swing.JLabel();
        BarradeTarefasjToolBar = new javax.swing.JToolBar();
        adicionarAPagarjButton = new javax.swing.JButton();
        editarAPagarjButton = new javax.swing.JButton();
        ExcluirAPagarjButton = new javax.swing.JButton();
        liquidarAPagarjButton = new javax.swing.JButton();
        pesquisarAPagarjButton = new javax.swing.JButton();
        SeparadordeTarefasjSeparator = new javax.swing.JToolBar.Separator();
        imprimirTelajButton = new javax.swing.JButton();
        visualizarAPagarjButton = new javax.swing.JButton();
        relatorioAPagarjButton = new javax.swing.JButton();
        voltarTelajButton = new javax.swing.JButton();
        contasjTabbedPane = new javax.swing.JTabbedPane();
        vencendojScrollPane = new javax.swing.JScrollPane();
        vencendojTable = new javax.swing.JTable();
        vencerjScrollPane = new javax.swing.JScrollPane();
        vencerjTable = new javax.swing.JTable();
        vencidasjScrollPane = new javax.swing.JScrollPane();
        vencidasjTable = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        valorVencerjLabel = new javax.swing.JLabel();
        totalPagarjLabel = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        valorVencendojLabel = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        TotalVencendojLabel2 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        valorPagarjLabel = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        valorVencidasjLabel = new javax.swing.JLabel();
        totalVencendojLabel = new javax.swing.JLabel();
        totalVencerjLabel = new javax.swing.JLabel();
        totalVencidasjLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Consulta Contas a Pagar");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        URL url = this.getClass().getResource("/imagens/logo_mini.png");
        Image imagemTitulo = Toolkit.getDefaultToolkit().getImage(url);
        this.setIconImage(imagemTitulo);
        try{
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
        }catch (Exception e){
            e.printStackTrace();
        }
        AssociadosjPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        AssociadosjPanel.setPreferredSize(new java.awt.Dimension(800, 600));
        AssociadosjPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        nomeCedentejTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nomeCedentejTextFieldKeyPressed(evt);
            }
        });
        AssociadosjPanel.add(nomeCedentejTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 37, 490, -1));

        nomeCedentejLabel.setText("Nome do Cedente");
        AssociadosjPanel.add(nomeCedentejLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));

        BarradeTarefasjToolBar.setFloatable(false);
        BarradeTarefasjToolBar.setRollover(true);

        adicionarAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/dinheiromais.png"))); // NOI18N
        adicionarAPagarjButton.setText("Adicionar");
        adicionarAPagarjButton.setToolTipText("Adicionar Contas a Pagar");
        adicionarAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        adicionarAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        adicionarAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        adicionarAPagarjButton.setName(""); // NOI18N
        adicionarAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        adicionarAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        adicionarAPagarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adicionarAPagarjButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(adicionarAPagarjButton);

        editarAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/dinheiroedit.png"))); // NOI18N
        editarAPagarjButton.setText("Editar");
        editarAPagarjButton.setToolTipText("Editar Contas a Pagar");
        editarAPagarjButton.setEnabled(false);
        editarAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        editarAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        editarAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        editarAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarAPagarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarAPagarjButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(editarAPagarjButton);

        ExcluirAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/dinheiromenos.png"))); // NOI18N
        ExcluirAPagarjButton.setText("Excluir");
        ExcluirAPagarjButton.setToolTipText("Excluir Contas a Pagar");
        ExcluirAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ExcluirAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        ExcluirAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        ExcluirAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        ExcluirAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        ExcluirAPagarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExcluirAPagarjButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(ExcluirAPagarjButton);

        liquidarAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/money2.png"))); // NOI18N
        liquidarAPagarjButton.setText("Liquidar");
        liquidarAPagarjButton.setToolTipText("Liquidar Contas a Pagar");
        liquidarAPagarjButton.setEnabled(false);
        liquidarAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        liquidarAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        liquidarAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        liquidarAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        liquidarAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        liquidarAPagarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                liquidarAPagarjButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(liquidarAPagarjButton);

        pesquisarAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pesquisar.png"))); // NOI18N
        pesquisarAPagarjButton.setText("Pesquisar");
        pesquisarAPagarjButton.setToolTipText("Pesquisar Contas a Pagar");
        pesquisarAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        pesquisarAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        pesquisarAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        pesquisarAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        pesquisarAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        pesquisarAPagarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pesquisarAPagarjButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(pesquisarAPagarjButton);
        BarradeTarefasjToolBar.add(SeparadordeTarefasjSeparator);

        imprimirTelajButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/impressao.png"))); // NOI18N
        imprimirTelajButton.setText("Imprimir");
        imprimirTelajButton.setToolTipText("Imprimir");
        imprimirTelajButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imprimirTelajButton.setMaximumSize(new java.awt.Dimension(80, 90));
        imprimirTelajButton.setMinimumSize(new java.awt.Dimension(80, 90));
        imprimirTelajButton.setPreferredSize(new java.awt.Dimension(80, 90));
        imprimirTelajButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BarradeTarefasjToolBar.add(imprimirTelajButton);

        visualizarAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/visualizar.png"))); // NOI18N
        visualizarAPagarjButton.setText("Visualizar");
        visualizarAPagarjButton.setToolTipText("Visualizar Cadastro");
        visualizarAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        visualizarAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        visualizarAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        visualizarAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        visualizarAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BarradeTarefasjToolBar.add(visualizarAPagarjButton);

        relatorioAPagarjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/relatorio.png"))); // NOI18N
        relatorioAPagarjButton.setText("Relatórios");
        relatorioAPagarjButton.setToolTipText("Relatórios");
        relatorioAPagarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        relatorioAPagarjButton.setMaximumSize(new java.awt.Dimension(80, 90));
        relatorioAPagarjButton.setMinimumSize(new java.awt.Dimension(80, 90));
        relatorioAPagarjButton.setPreferredSize(new java.awt.Dimension(80, 90));
        relatorioAPagarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        BarradeTarefasjToolBar.add(relatorioAPagarjButton);

        voltarTelajButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/voltar.png"))); // NOI18N
        voltarTelajButton.setText("Voltar");
        voltarTelajButton.setToolTipText("Voltar");
        voltarTelajButton.setFocusable(false);
        voltarTelajButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        voltarTelajButton.setMaximumSize(new java.awt.Dimension(80, 90));
        voltarTelajButton.setMinimumSize(new java.awt.Dimension(80, 90));
        voltarTelajButton.setPreferredSize(new java.awt.Dimension(80, 90));
        voltarTelajButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        voltarTelajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                voltarTelajButtonActionPerformed(evt);
            }
        });
        BarradeTarefasjToolBar.add(voltarTelajButton);

        AssociadosjPanel.add(BarradeTarefasjToolBar, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 470, 740, 80));

        contasjTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                contasjTabbedPaneStateChanged(evt);
            }
        });
        contasjTabbedPane.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
                contasjTabbedPaneAncestorMoved(evt);
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        vencendojTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Nº Conta", "Data Conta", "Cedente", "Data Vencimento", "Valor Conta"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        vencendojTable.getColumnModel().getColumn(0).setPreferredWidth(30);
        vencendojTable.getColumnModel().getColumn(1).setPreferredWidth(30);
        vencendojTable.getColumnModel().getColumn(2).setPreferredWidth(300);
        vencendojTable.getColumnModel().getColumn(3).setPreferredWidth(30);
        vencendojTable.getColumnModel().getColumn(4).setPreferredWidth(30);
        vencendojTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                vencendojTableMouseClicked(evt);
            }
        });
        vencendojScrollPane.setViewportView(vencendojTable);
        vencendojTable.getColumnModel().getColumn(0).setPreferredWidth(20);
        vencendojTable.getColumnModel().getColumn(1).setPreferredWidth(20);
        vencendojTable.getColumnModel().getColumn(2).setPreferredWidth(300);
        vencendojTable.getColumnModel().getColumn(3).setPreferredWidth(20);
        vencendojTable.getColumnModel().getColumn(4).setPreferredWidth(20);

        contasjTabbedPane.addTab("Contas Vencendo", vencendojScrollPane);

        vencerjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Nº Conta", "Data Conta", "Cedente", "Data Vencimento", "Valor Conta"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        vencerjTable.getColumnModel().getColumn(0).setPreferredWidth(30);
        vencerjTable.getColumnModel().getColumn(1).setPreferredWidth(30);
        vencerjTable.getColumnModel().getColumn(2).setPreferredWidth(300);
        vencerjTable.getColumnModel().getColumn(3).setPreferredWidth(30);
        vencerjTable.getColumnModel().getColumn(4).setPreferredWidth(30);
        vencerjTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                vencerjTableMouseClicked(evt);
            }
        });
        vencerjScrollPane.setViewportView(vencerjTable);

        contasjTabbedPane.addTab("Contas a Vencer", vencerjScrollPane);

        vencidasjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Nº Conta", "Data Conta", "Cedente", "Data Vencimento", "Valor Conta"
            }
        ));
        vencidasjTable.getColumnModel().getColumn(0).setPreferredWidth(30);
        vencidasjTable.getColumnModel().getColumn(1).setPreferredWidth(30);
        vencidasjTable.getColumnModel().getColumn(2).setPreferredWidth(300);
        vencidasjTable.getColumnModel().getColumn(3).setPreferredWidth(30);
        vencidasjTable.getColumnModel().getColumn(4).setPreferredWidth(30);
        vencidasjTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                vencidasjTableMouseClicked(evt);
            }
        });
        vencidasjScrollPane.setViewportView(vencidasjTable);

        contasjTabbedPane.addTab("Contas Vencidas", vencidasjScrollPane);

        AssociadosjPanel.add(contasjTabbedPane, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 830, 330));

        jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        valorVencerjLabel.setFont(new java.awt.Font("Times New Roman", 1, 36));
        valorVencerjLabel.setForeground(new java.awt.Color(0, 153, 0));
        valorVencerjLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        valorVencerjLabel.setText("0,00");
        jPanel3.add(valorVencerjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, 120, -1));

        AssociadosjPanel.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 420, 160, 40));

        totalPagarjLabel.setText("Total a Pagar");
        AssociadosjPanel.add(totalPagarjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 402, -1, -1));

        jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        valorVencendojLabel.setFont(new java.awt.Font("Times New Roman", 1, 36));
        valorVencendojLabel.setForeground(java.awt.Color.blue);
        valorVencendojLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        valorVencendojLabel.setText("0,00");
        jPanel4.add(valorVencendojLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, 120, -1));

        AssociadosjPanel.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 420, 160, 40));

        jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        TotalVencendojLabel2.setFont(new java.awt.Font("Times New Roman", 1, 36));
        TotalVencendojLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        TotalVencendojLabel2.setText("0,00");
        jPanel5.add(TotalVencendojLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, 120, -1));

        AssociadosjPanel.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 420, 160, 40));

        jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        valorPagarjLabel.setFont(new java.awt.Font("Times New Roman", 1, 36));
        valorPagarjLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        valorPagarjLabel.setText("0,00");
        jPanel6.add(valorPagarjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, 120, -1));

        AssociadosjPanel.add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 420, 160, 40));

        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel7.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        valorVencidasjLabel.setFont(new java.awt.Font("Times New Roman", 1, 36));
        valorVencidasjLabel.setForeground(java.awt.Color.red);
        valorVencidasjLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        valorVencidasjLabel.setText("0,00");
        jPanel7.add(valorVencidasjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, 120, -1));

        AssociadosjPanel.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 420, 160, 40));

        totalVencendojLabel.setText("Total Vencendo");
        AssociadosjPanel.add(totalVencendojLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 402, -1, -1));

        totalVencerjLabel.setText("Total a Vencer");
        AssociadosjPanel.add(totalVencerjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 402, -1, -1));

        totalVencidasjLabel.setText("Total Vencidas");
        AssociadosjPanel.add(totalVencidasjLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 400, -1, -1));

        getContentPane().add(AssociadosjPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 860, 560));

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void nomeCedentejTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nomeCedentejTextFieldKeyPressed
//        String cedente = nomeCedentejTextField.getText();
//        if (contasjTabbedPane.getSelectedIndex() == 0) {
//            List listaCedente = contasPagarDAO.pesquisaCedenteVencendo(cedente, dataDoDia);
//            modelVencendo.listaContasVencendo = listaCedente;
//            modelVencendo.fireTableDataChanged();
//        } else if (contasjTabbedPane.getSelectedIndex() == 1) {
//            List listaCedente = contasPagarDAO.pesquisaCedenteVencer(cedente, dataDoDia);
//            modelVencer.listaContasVencer = listaCedente;
//            modelVencer.fireTableDataChanged();
//        } else if (contasjTabbedPane.getSelectedIndex() == 2) {
//            List listaCedente = contasPagarDAO.pesquisaCedenteVencidos(cedente, dataDoDia);
//            modelVencidas.listaContasVencidas = listaCedente;
//            modelVencidas.fireTableDataChanged();
//        }
    }//GEN-LAST:event_nomeCedentejTextFieldKeyPressed
    private void adicionarAPagarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adicionarAPagarjButtonActionPerformed
        new FrmCadastraPagar(new ContasPagar());
    }//GEN-LAST:event_adicionarAPagarjButtonActionPerformed
    private void editarAPagarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarAPagarjButtonActionPerformed
        if (contasjTabbedPane.getSelectedIndex() == 0) {
            int linha = vencendojTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencendo.listaContasVencendo.get(linha);
                new FrmCadastraPagar(contasPagar);
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 1) {
            int linha = vencerjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencer.listaContasVencer.get(linha);
                new FrmCadastraPagar(contasPagar);
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 2) {
            int linha = vencidasjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencidas.listaContasVencidas.get(linha);
                new FrmCadastraPagar(contasPagar);
            }
        }
    }//GEN-LAST:event_editarAPagarjButtonActionPerformed
    private void vencendojTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_vencendojTableMouseClicked
        if (vencendojTable.getSelectedRow() >= 0) {
            editarAPagarjButton.setEnabled(true);
            liquidarAPagarjButton.setEnabled(true);
        }
    }//GEN-LAST:event_vencendojTableMouseClicked
    private void vencerjTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_vencerjTableMouseClicked
        if (vencerjTable.getSelectedRow() >= 0) {
            editarAPagarjButton.setEnabled(true);
            liquidarAPagarjButton.setEnabled(true);
        }
    }//GEN-LAST:event_vencerjTableMouseClicked
    private void vencidasjTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_vencidasjTableMouseClicked
        if (vencidasjTable.getSelectedRow() >= 0) {
            editarAPagarjButton.setEnabled(true);
            liquidarAPagarjButton.setEnabled(true);
        }
    }//GEN-LAST:event_vencidasjTableMouseClicked
    private void ExcluirAPagarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExcluirAPagarjButtonActionPerformed
        if (contasjTabbedPane.getSelectedIndex() == 0) {
            int linha = vencendojTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencendo.listaContasVencendo.get(linha);
                try {
                    contasPagarDAO.excluir(contasPagar);
                    JOptionPane.showMessageDialog(this, "Dados excluidos com sucesso");
                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(this, "Dados não foram excluidos");
                }
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 1) {
            int linha = vencerjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencer.listaContasVencer.get(linha);
                try {
                    contasPagarDAO.excluir(contasPagar);
                    JOptionPane.showMessageDialog(this, "Dados excluidos com sucesso");
                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(this, "Dados não foram excluidos");
                }
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 2) {
            int linha = vencidasjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencidas.listaContasVencidas.get(linha);
                try {
                    contasPagarDAO.excluir(contasPagar);
                    JOptionPane.showMessageDialog(this, "Dados excluidos com sucesso");
                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(this, "Dados não foram excluidos");
                }
            }
        }
    }//GEN-LAST:event_ExcluirAPagarjButtonActionPerformed
    private void liquidarAPagarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_liquidarAPagarjButtonActionPerformed
        if (contasjTabbedPane.getSelectedIndex() == 0) {
            int linha = vencendojTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencendo.listaContasVencendo.get(linha);
                new FrmLiquidaPagar(contasPagar);
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 1) {
            int linha = vencerjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencer.listaContasVencer.get(linha);
                new FrmLiquidaPagar(contasPagar);
            }
        } else if (contasjTabbedPane.getSelectedIndex() == 2) {
            int linha = vencidasjTable.getSelectedRow();
            if (linha >= 0) {
                ContasPagar contasPagar = modelVencidas.listaContasVencidas.get(linha);
                new FrmLiquidaPagar(contasPagar);
            }
        }
    }//GEN-LAST:event_liquidarAPagarjButtonActionPerformed

    private void voltarTelajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_voltarTelajButtonActionPerformed
        this.dispose();
    }//GEN-LAST:event_voltarTelajButtonActionPerformed

    private void pesquisarAPagarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pesquisarAPagarjButtonActionPerformed
        new FrmPesquisaPagar();
    }//GEN-LAST:event_pesquisarAPagarjButtonActionPerformed

    private void contasjTabbedPaneAncestorMoved(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_contasjTabbedPaneAncestorMoved
    }//GEN-LAST:event_contasjTabbedPaneAncestorMoved

    private void contasjTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_contasjTabbedPaneStateChanged
        try{
        if (contasjTabbedPane.getSelectedIndex() == 0) {
            vencendojTable.setModel(modelVencendo);
            System.out.println("VENCENDO");
            vencendojTable.getColumnModel().getColumn(0).setPreferredWidth(100);
            vencendojTable.getColumnModel().getColumn(1).setPreferredWidth(80);
            vencendojTable.getColumnModel().getColumn(2).setPreferredWidth(300);
            vencendojTable.getColumnModel().getColumn(3).setPreferredWidth(80);
            vencendojTable.getColumnModel().getColumn(4).setPreferredWidth(80);
        } else if (contasjTabbedPane.getSelectedIndex() == 1) {
            vencerjTable.setModel(modelVencer);
            vencerjTable.getColumnModel().getColumn(0).setPreferredWidth(100);
            vencerjTable.getColumnModel().getColumn(1).setPreferredWidth(80);
            vencerjTable.getColumnModel().getColumn(2).setPreferredWidth(300);
            vencerjTable.getColumnModel().getColumn(3).setPreferredWidth(80);
        } else if (contasjTabbedPane.getSelectedIndex() == 2) {
            vencidasjTable.setModel(modelVencidas);
            System.out.println("VENCIDAS");
            vencidasjTable.getColumnModel().getColumn(0).setPreferredWidth(100);
            vencidasjTable.getColumnModel().getColumn(1).setPreferredWidth(80);
            vencidasjTable.getColumnModel().getColumn(2).setPreferredWidth(300);
            vencidasjTable.getColumnModel().getColumn(3).setPreferredWidth(80);
        }
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }//GEN-LAST:event_contasjTabbedPaneStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel AssociadosjPanel;
    private javax.swing.JToolBar BarradeTarefasjToolBar;
    private javax.swing.JButton ExcluirAPagarjButton;
    private javax.swing.JToolBar.Separator SeparadordeTarefasjSeparator;
    private javax.swing.JLabel TotalVencendojLabel2;
    private javax.swing.JButton adicionarAPagarjButton;
    private javax.swing.JTabbedPane contasjTabbedPane;
    private javax.swing.JButton editarAPagarjButton;
    private javax.swing.JButton imprimirTelajButton;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JButton liquidarAPagarjButton;
    private javax.swing.JLabel nomeCedentejLabel;
    private javax.swing.JTextField nomeCedentejTextField;
    private javax.swing.JButton pesquisarAPagarjButton;
    private javax.swing.JButton relatorioAPagarjButton;
    private javax.swing.JLabel totalPagarjLabel;
    private javax.swing.JLabel totalVencendojLabel;
    private javax.swing.JLabel totalVencerjLabel;
    private javax.swing.JLabel totalVencidasjLabel;
    private javax.swing.JLabel valorPagarjLabel;
    private javax.swing.JLabel valorVencendojLabel;
    private javax.swing.JLabel valorVencerjLabel;
    private javax.swing.JLabel valorVencidasjLabel;
    private javax.swing.JScrollPane vencendojScrollPane;
    private javax.swing.JTable vencendojTable;
    private javax.swing.JScrollPane vencerjScrollPane;
    private javax.swing.JTable vencerjTable;
    private javax.swing.JScrollPane vencidasjScrollPane;
    private javax.swing.JTable vencidasjTable;
    private javax.swing.JButton visualizarAPagarjButton;
    private javax.swing.JButton voltarTelajButton;
    // End of variables declaration//GEN-END:variables
    private ContasPagarDAO contasPagarDAO;
    private ConsultaContasVencendoTableModel modelVencendo;
    private ConsultaContasVencerTableModel modelVencer;
    private ConsultaContasVencidasTableModel modelVencidas;
}
